﻿// JScript File
function writeDateInfo()
{
var day="";
var month="";
var ampm="";
var ampmhour="";
var myweekday="";
var year="";
mydate=new Date();
myweekday=mydate.getDay();
mymonth=mydate.getMonth()+1;
myday= mydate.getDate();
myyear= mydate.getYear();
year=(myyear > 200) ? myyear : 1900 + myyear;
if(myweekday == 0)
weekday=" 星期日";
else if(myweekday == 1)
weekday=" 星期一";
else if(myweekday == 2)
weekday=" 星期二";
else if(myweekday == 3)
weekday=" 星期三";
else if(myweekday == 4)
weekday=" 星期四";
else if(myweekday == 5)
weekday=" 星期五";
else if(myweekday == 6)
weekday=" 星期六";
document.write("<a href='#'title='点此查看今日万年历' onclick=\"window.open('http://www.0460.com/tools/life/wannianli.htm')\"  target='_self'>" + year+"年"+mymonth+"月"+myday+"日"+weekday + "</a>");
}

function $(i) { return document.getElementById(i);}

function copy_to_clip()
{
	var obj = window.clipboardData;
	obj.setData('Text','这个网页或许对你有用处,网址是:'+ document.location.href );
	alert('你已经成功复制本链接地址，好东西当然要发给QQ/MSN好友分享了');
}

function copyToClipBoardIndex()
{ 
    var clipBoardContent=""; 
    clipBoardContent+="这个网页或许对你有用处，有空看看:"; 
    clipBoardContent+=""; 
    clipBoardContent+=document.location.href; 
    window.clipboardData.setData("Text",clipBoardContent); 
    alert("您已经成功复制本页链接，您现在可以通过QQ/MSN分享给您的好友了"); 
} 

function  setWindowStatus()
{
    window.status='如果你喜欢0460网站之家（Www.0460.Com），请推荐给你身边的朋友，谢谢！';
    return true;
}

function clect()
{
	window.open('http://shuqian.qq.com/post?from=3&title=' + encodeURIComponent(document.title) + '&uri='+encodeURIComponent(document.location.href) + '&jumpback=2&noui=1','favit','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)
}

function JSAddFavorite(){
	if ( window.sidebar && "object" == typeof( window.sidebar ) && "function" == typeof( window.sidebar.addPanel ) ){
  	//  firefox
		window.sidebar.addPanel( document.title, document.location.href, '' );
	}else if ( document.all && "object" == typeof( window.external ) ){
    //  ie
//    window.external.addFavorite( document.location.href, document.title );
    window.external.addFavorite( document.location.href, '_25A1_25EF2523_25C4_25EA_25C7_25E1_25B5_25BC_25BA_25BD Www.0460.Com_25A1_25EF' );
  }
}

function CheckImg(imgName, iType)
{
    var oFile = document.getElementById(imgName);
    if(iType == 1)
    {
        if(oFile.value == "") 
        { 
            alert('图片为空.');
            return false;
        }
    }
    return true;
    

}
function CheckImgSize(imgName)
{
    var oFile = document.getElementById(imgName);
    if(oFile.value != "")
    {
        var image = new Image();
        image.src = oFile.value;
        alert(image.fileSize);
    }
}


function m() { 
    if (event.keyCode == 13) { 
        return false;
    } 
    else
    {
        return true;
    }
}

function GetCookie(sName) {
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++) {
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) 
		{
		    if(unescape(aCrumb[1]) != "undefined")
		    {
			    return unescape(aCrumb[1]);
			}
			else
			{
			    return "";
			}
			
		}
	}
	return "";
}


function showConfirm(sText){
    var returnValue = confirm(sText);
    //增加js中 confirm 对 取消 确定按钮时间的单独处理;
    
    if(returnValue==undefined | returnValue==false){ return false;}
    else{ 
        popSign();
        return true;}
}


function   lockScreen(){ 
    popCoverDiv();
    //document.body.style.overflow = "hidden";                  
}

function popSign(){
   lockScreen();
   var loginDivWidth = 300;
   var sign_in_flow = '<div style="background:#FFE3D6;font-size:13px;">提示</div><div></div><div>'
       + ''
       + '</div><div></div><div style=\"padding:16px 2px 24px 2px;font-size:12px;\"><img src=\"/images/progress.gif\">正在处理中,请稍候...'
        + '</div><div></div>';

   if (G("sign_div")) {
    G("sign_div").style.display = '';
   } else {
    var signDiv = GC('div');
    document.body.appendChild(signDiv);
    signDiv.id = 'sign_div';
    signDiv.align = "center";

    with (signDiv.style) {
     position = 'absolute';
     left = (document.documentElement.clientWidth - loginDivWidth)/2 + 'px';
     top =  (document.documentElement.clientHeight - 200)/2 + document.documentElement.scrollTop;
     width = loginDivWidth + 'px';
     zIndex = 99;
     background = '#FFFFFF';
     border = '#DE6900 solid 1px';
    }
   }
    G("sign_div").innerHTML = sign_in_flow;
}

function G(id){
    return document.getElementById(id);
};
function GC(t){
   return document.createElement(t);
};
String.prototype.trim = function(){
          return this.replace(/(^\s*)|(\s*$)/g, '');
};
function isIE(){
      return (document.all && window.ActiveXObject && !window.opera) ? true : false;
} 

function cancelCover(){
    if(G("cover_div") != null)
    {
        G("cover_div").style.display = 'none';
        document.body.style.overflow = '';
    }
};

function cancelSign(){
    if(G("sign_div") != null)
    {
        G("sign_div").style.display = 'none';
        document.body.style.overflow = '';
    }
};

function popCoverDiv(){
   if (G("cover_div")) {
    G("cover_div").style.display = '';
   } else {
    var coverDiv = GC('div');
    document.body.appendChild(coverDiv);
    coverDiv.id = 'cover_div';
    with(coverDiv.style) {
     position = 'absolute';
     background = '#CCCCCC';
     left = '0px';
     top = '0px';
     var bodySize = getBodySize();
     width = bodySize[0] + 'px'
     height = bodySize[1] + 'px';
     zIndex = 98;
     if (isIE()) {
      filter = "Alpha(Opacity=60)";
     } else {
      opacity = 0.6;
     }
    }
   }
}
function getBodySize(){
   var bodySize = [];
   with(document.documentElement) {
    bodySize[0] = (scrollWidth>clientWidth)?scrollWidth:clientWidth;
    bodySize[1] = (scrollHeight>clientHeight)?scrollHeight:clientHeight;
   }
   return bodySize;
}


function   lockScreen2()
{ 
    var   oDiv = document.createElement( "DIV "); 
    var   w,h; 
    w   = window.screen.width;   //screen.availWidth; 
    h   = window.screen.height;  //screen.availHeight;  
                 
    oDiv.style.top   =   0; 
    oDiv.style.left   =   0; 
    oDiv.style.width   =   w; 
    oDiv.style.height   =   h; 
    oDiv.style.zIndex   =   10000; 
    oDiv.style.backgroundColor   =   "gray"; 
    oDiv.style.filter   =   "alpha(opacity=50)"; 
    //document.body.insertAdjacentElement( "beforeEnd ",oDiv);
    document.body.appendChild(oDiv);
    
    //document.bgColor = "gray";
    //document.filter = "alpha(opacity=50)";
}


function SetNameBlank(sName, sValue)
{
    if(document.getElementById(sName).getAttribute("value") == sValue)
	{
        document.getElementById(sName).setAttribute("value", "");
    }
}

function newwindow() 
{ 
    var url;
    url = "Refresh.aspx";
    window.open(url,'windowR',"height=165, width=380, toolbar=no , menubar=no, scrollbars=NO, resizable=no, location=no, status=no,left="+(screen.width-400)/2+",top="+(screen.height-200)/2);
}

function SetBlank(o)
{
    document.getElementById(o).innerHTML = "";
}

function PreviewPic(sPicPath, sPicBox, width, height)
{
    //sPicPath 
    try{
        var newPreview = document.getElementById(sPicBox);
        newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = sPicPath;
        newPreview.style.width = width;
        newPreview.style.height = height;
        newPreview.innerHTML = "";
    }
    catch(err){}
}

function CheckSelectdText(oBoxList, sText)
{
    var oTag = false;
          var objs  = document.getElementById(oBoxList).getElementsByTagName("INPUT");   
          for(var i = 0; i < objs.length; i++)     
          {   
                if(objs[i].type.toLowerCase()   ==   "checkbox" )   
                {   
                    if(objs[i].checked   ==   true)
                    {
                        oTag = true;  
                        break;
                    }  
                }   
          }
   if(oTag == false)
   {
        alert('请至少选择一个项!');
        return false;
   }
   else
   {
        return confirm(sText);
   }
}

function CheckSelectd(oBoxList)
{
    var oTag = false;
          var objs  = document.getElementById(oBoxList).getElementsByTagName("INPUT");   
          for(var i = 0; i < objs.length; i++)     
          {   
                if(objs[i].type.toLowerCase()   ==   "checkbox" )   
                {   
                    if(objs[i].checked   ==   true)
                    oTag = true;    
                }   
          }
   if(oTag == false)
   {
        alert('请至少选择一个项!');
        return false;
   }
   else
   {
        return confirm('确定要删除所选择项吗?');
   }
}

  function   SelectAll(oBoxList)   
  {   
          var objs  = document.getElementById(oBoxList).getElementsByTagName("INPUT");   
          for(var i = 0; i < objs.length; i++)     
          {   
                if(objs[i].type.toLowerCase()   ==   "checkbox" )   
                {   
                    if(objs[i].checked   ==   false)   
                        objs[i].checked   =   true;     
                }   
          }   
  } 
  
  function SelectByAllBox(oBoxList)
  {
         var oTag = document.getElementById("SelectBox").checked;   //适用 Firefox Ie //getAtributes适合ie.
         var objs  = document.getElementById(oBoxList).getElementsByTagName("INPUT");   
         for(var i = 0; i < objs.length; i++)     
         { 
                if(oTag == true)
                {
                    if(objs[i].name != 'SelectBox'  && objs[i].type.toLowerCase()   ==   "checkbox" )   
                    {
                        if(objs[i].checked   ==   false)   
                            objs[i].checked   =   true; 
                    }
                }
                else
                {
                    if(objs[i].name != 'SelectBox'  && objs[i].type.toLowerCase()   ==   "checkbox" )   
                    {
                        if(objs[i].checked   ==   true)   
                            objs[i].checked   =   false; 
                    }
                }
         } 
  }
  
  function   SelectNotCheck(oBoxList)   
  {   
          var objs  = document.getElementById(oBoxList).getElementsByTagName("INPUT");   
          for(var i = 0; i < objs.length; i++)     
          {   
                if(objs[i].name != 'SelectBox'  && objs[i].type.toLowerCase()   ==   "checkbox" )   
                {   
                    if(objs[i].checked   ==   false)   
                        objs[i].checked   =   true;   
                    else   
                        objs[i].checked   =   false;   
                }   
          }   
  }
  
function setHomepage()
{
if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
       document.body.setHomePage('../www.0460.com/#.htm');

    }
    else if (window.sidebar)
    {
    if(window.netscape)
    {
         try
        {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
         }
         catch (e)
         {
            alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );
         }
    }
    var prefs = Components.classes['_40mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage','../www.0460.com/#2.htm');
    }
}

// Link Box
function ntabs(thisObj,Num){
    if(thisObj.className == "active")return;
    var tabObj = thisObj.parentNode.id;
    var tabList = document.getElementById(tabObj).getElementsByTagName("li");
    for(i=0; i <tabList.length - 1; i++)
    {
        if (i == Num)
        {
            thisObj.className = "active"; 
            document.getElementById(tabObj + "_content"+i).style.display = "block";
        }
        else{
            tabList[i].className = "normal"; 
            document.getElementById(tabObj + "_content"+i).style.display = "none";
        }
    } 
}